from django.contrib import admin
from cmdb.models import Idc, Ip, Host, HostInfo

# ip添加
class IpInline(admin.TabularInline):
    model = Ip


class HostInline(admin.TabularInline):
    model = Host


class  HostAdmin(admin.ModelAdmin):
    # 搜所功能展示
    list_display = ('idc', 'date_added', 'hostname', 'number', 'application',)
    search_fields = ['hostname',]
    list_filter = ('hostname',)
    inlines = [IpInline, ]


class IdcAdmin(admin.ModelAdmin):
    inlines = [HostInline,]

class IpAdmin(admin.ModelAdmin):
    list_display = ('ip',)


admin.site.register(Idc,IdcAdmin)
admin.site.register(Ip, IpAdmin)
admin.site.register(Host, HostAdmin)
admin.site.register(HostInfo)

